package com.hlx.tools;

import com.hlx.entiry.dto.MajorDTO;
import com.hlx.entiry.po.ConsultationAppointment;
import com.hlx.entiry.vo.MajorVO;
import com.hlx.service.MajorService;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
public class MajorTool {

	private final MajorService majorService;

	@Tool(description = "根据条件查询专业信息")
	public List<MajorVO> queryMajor(@ToolParam(required = false, description = "查询的条件") MajorDTO majorDTO) {
		List<MajorVO> list = majorService.queryMajor(majorDTO);
		return list;
	}

	@Tool(description = "查询全部学院信息")
	public List<String> queryAllCollege() {
		List<String> list = majorService.queryAllCollege();
		return list;
	}

	@Tool(description = "根据学院名称查询所有专业信息")
	public List<MajorVO> queryMajorByCollege(@ToolParam(description = "学院名称") String collegeName) {
		List<MajorVO> list = majorService.queryMajorByCollege(collegeName);
		return list;
	}

	@Tool(description = "⽣成预约单,并返回⽣成的预约单号")
	public Integer generateAppointmentOrder(
			@ToolParam(description = "预约表") String username,
			@ToolParam(description = "联系方式") String contact,
			@ToolParam(description = "想了解的学院或专业") String targetInfo,
			@ToolParam(required = false, description = "备注") String notes) {
		ConsultationAppointment appointment = new ConsultationAppointment();
		appointment.setUsername(username);
		appointment.setContact(contact);
		appointment.setTargetInfo(targetInfo);
		appointment.setNotes(notes);
		majorService.generateAppointmentOrder(appointment);
		return appointment.getId();
	}

}
